package com.chuangke.system.controller;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.chuangke.common.db.page.CkPageQuery;
import com.chuangke.common.http.HttpResult;
import com.chuangke.system.entity.SysMeasureGroup;
import com.chuangke.system.service.SysMeasureGroupService;

@RestController
@RequestMapping("/system/measure/group")
public class SysMeasureGroupController {
	@Autowired
    private SysMeasureGroupService sysMeasureGroupService;
	/**
     * 	查询
     */
    @PreAuthorize("hasAuthority('login:action')")
    @GetMapping("/page")
    public HttpResult page(Map<String,Object> map) {
        return HttpResult.ok(sysMeasureGroupService.findPage(new CkPageQuery(map)));
    }
    
    /**
     * 	删除
     */
    @PreAuthorize("hasAuthority('login:action')")
    @PostMapping("/delete")
    public HttpResult batchDelete(@RequestBody List<String> ids) {
    	sysMeasureGroupService.deleteDatas(ids);
        return HttpResult.ok();
    }
    
    /**
     * 	保存
     */
    @PreAuthorize("hasAuthority('login:action')")
    @PostMapping("/save")
    public HttpResult save(@RequestBody SysMeasureGroup sysMeasureGroup) {
    	sysMeasureGroupService.saveOrUpdateData(sysMeasureGroup);
        return HttpResult.ok();
    }
}
